package com.wholesale.beans;

import java.util.Date;
import org.json.JSONException;
import org.json.JSONObject;

public class Feedback {
	
	private boolean isReply ;
	private String messageImg ;
	private String msgContent ;
	private int msgId ;
	private String msgTime ;
	private String msgTitle ;
	private int msgType ;
	private int orderId ;
	private Feedback reply ;
	private String userEmail ;
	private int userId ;
	private String userName ;
    private	JSONObject jsonObject;
	
	public String getMessageImg() {
		
		return messageImg;
	}
	public void setMessageImg(String messageImg) {
		this.messageImg = messageImg;
	}
	public String getMsgContent() {
		
		return msgContent;
	}
	public void setMsgContent(String msgContent) {
		this.msgContent = msgContent;
	}
	public int getMsgId() {
		
		return msgId;
	}
	public void setMsgId(int msgId) {
		this.msgId = msgId;
	}
	public String getMsgTime() {
		
			return msgTime;
	}
	public void setMsgTime(String msgTime) {
		this.msgTime = msgTime;
	}
	public String getMsgTitle() {
		
		return msgTitle;
	}
	public void setMsgTitle(String msgTitle) {
		this.msgTitle = msgTitle;
	}
	public int getMsgType() {
		
		return msgType;
	}
	public void setMsgType(int msgType) {
		this.msgType = msgType;
	}
	public int getOrderId() {
		
		return orderId;
	}
	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}
	public Feedback getReply() {
		
		return reply;
	}
	public void setReply(Feedback reply) {
		this.reply = reply;
	}
	public boolean isReply() {
		
		return isReply;
	}
	public void setReply(boolean isReply) {
		this.isReply = isReply;
	}
	public String getUserEmail() {
		
		return userEmail;
	}
	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}
	public int getUserId() {
		
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public String getUserName() {
		
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public String toJsonString(){
		JSONObject jsonObject = new JSONObject();
		try {
//			jsonObject.put("msgId", msgId);
			jsonObject.put("userId", userId);
			jsonObject.put("userName", userName);
			jsonObject.put("userEmail", userEmail);
			jsonObject.put("msgTitle", msgTitle);
			jsonObject.put("msgType", msgType);
			jsonObject.put("msgContent", msgContent);
//			jsonObject.put("msgTime", msgTime);
//			jsonObject.put("messageImg", messageImg);
//			jsonObject.put("orderId", orderId);
//			if(isReply){
//				jsonObject.put("messageImg", 1);
//			}else{
//				jsonObject.put("messageImg", 0);
//			}
		} catch (Exception e) {
		}
		return jsonObject.toString();
	}
	
	public void jsonAnalytic(String jsonString){
		//JSONObject jsonObject;
		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void jsonAnalytic(JSONObject jsonObject){
		this.jsonObject = jsonObject;
		
			try {
				msgId = jsonObject.getInt("msgId");
			} catch (JSONException e) {
			}
			try {
				userId = jsonObject.getInt("userId");
			} catch (JSONException e) {
			}
			try {
				userName = jsonObject.getString("userName");
			} catch (JSONException e) {
			
			}
			try {
				userEmail = jsonObject.getString("userEmail");
			} catch (JSONException e) {
				
			}
			try {
				msgTitle = jsonObject.getString("msgTitle");
			} catch (JSONException e) {
				
			}
			try {
				msgType = jsonObject.getInt("msgType");
			} catch (JSONException e) {
				
			}
			try {
				msgContent = jsonObject.getString("msgContent");
			} catch (JSONException e) {
				
			}
			try {
				msgTime = jsonObject.getString("msgTime");
			} catch (JSONException e) {
				
			}
			try {
				messageImg = jsonObject.getString("messageImg");
			} catch (JSONException e) {
				
			}
			try {
				orderId = jsonObject.getInt("orderId");
			} catch (JSONException e) {
				
			}
			try {
				if(!jsonObject.getString("isReply").equals("")&&jsonObject.getString("isReply").equals("1"))
				isReply = true;
			} catch (JSONException e) {
				// TODO Auto-generated catch block
			}
		
	}
}
